﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       Shpm.App.Input.Dao.HappyChamberlaineSrhDao
 * 类型：       DAO
 * 功能说明：   管家分配
 * 作者：       谈震鸣
 * 创建日期：   2007/11/22
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using Shpm.System.Db;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.App.Input.Bean;

namespace Shpm.App.Input.Dao
{
    public class HappyChamberlaineSrhDao : ShpmBaseDao
    {
        public const string FIND_BY_EMPLOYEE = "HappyChamberlaineSrh.FindByEmployee";
        public const string FIND_BY_MENBER = "HappyChamberlaineSrh.FindByMenber";
        public const string FIND_BY_MENBERHAVE = "HappyChamberlaineSrh.FindByMenberHave";
        public const string INSERT_MEMBERDOCTOR = "HappyChamberlaineSrh.InsertMemberDoctor";
        public const string UPDATE_DOCTOR = "HappyChamberlaineSrh.UpdateDoctor";
        public const string UPDATE_MENBER = "HappyChamberlaineSrh.UpdateMenber";
        public const string LIST_MENBER = "HappyChamberlaineSrh.ListMenberHave";

        public HappyChamberlaineSrhDao()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public IList ListMenber(HappyChamberlaineBean paramBean)
        {
            return base.QueryForList(LIST_MENBER, paramBean);
        }
        //读取管家列表
        public IList FindByEmployee(MstEmployeeBean paramBean)
        {
            return base.QueryForList(FIND_BY_EMPLOYEE, paramBean);
        }
        //读取会员列表
        public IList FindByMenber(HappyChamberlaineBean paramBean)
        {
            return base.QueryForList(FIND_BY_MENBER, paramBean);
        }

        //读取已有会员列表
        public IList FindByMenberHave(HappyChamberlaineBean paramBean)
        {
            return base.QueryForList(FIND_BY_MENBERHAVE, paramBean);
        }
        //插入新记录
        public Object InsertMemberDoctor(HappyChamberlaineBean paramBean)
        {
            return base.Insert(INSERT_MEMBERDOCTOR, paramBean);
        }
        //更新管家记录
        public int UpdateDoctor(HappyChamberlaineBean paramBean)
        {
            return base.Update(UPDATE_DOCTOR, paramBean);
        }
        //更新会员记录
        public int UpdateMenber(HappyChamberlaineBean paramBean)
        {
            return base.Update(UPDATE_MENBER, paramBean);
        }

        public int InsertMemberDoctorLst(IList datalist, string str,string strUserId)
        {
            try
            {
                HappyChamberlaineBean DoctorDataBean=new HappyChamberlaineBean ();
                DoctorDataBean.EmployeeId= str;
                DoctorDataBean.UserId = strUserId;
                base.BeginTransaction();
                this.UpdateDoctor(DoctorDataBean);
                foreach (HappyChamberlaineBean dataBean in datalist)
                {
                    this.UpdateMenber(dataBean);
                    this.InsertMemberDoctor(dataBean);
                }

                base.CommitTransaction();

                return datalist.Count;
            }
            catch (DataAccessException e)
            {
                Console.WriteLine("********** Exec  sql error! **********");
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                base.RollBackTransaction();
                throw e;
            }
            finally
            {

            }
        }
    }
    }